package com.yj.springbootsecuritydemo01.rest;

import com.yj.springbootsecuritydemo01.mapper.UserMapper;
import com.yj.springbootsecuritydemo01.pojo.UserEntity;
import com.yj.springbootsecuritydemo01.pojo.UserParam;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class UserController {

    @Resource
    private UserMapper userMapper;

    @Resource
    private PasswordEncoder passwordEncoder;

    @PostMapping("register")
    public String register(@RequestBody  UserParam userParam){

        userParam.setPassword(passwordEncoder.encode(userParam.getPassword()));
        userMapper.save(userParam);
        return "register success!";
    }

    @PostMapping("login")
    public String login(@RequestBody  UserParam userParam){



        return "login success!";
    }

    @GetMapping("get")
    public String get(){
        return "get method()";
    }

}
